package com.eoe.wiki.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.text.TextUtils;

public class DateUtil {

	public static final long MINUTE_MILLIS = 60*1000;
	public static final long HOUR_MILLIS = 60* MINUTE_MILLIS;
	public static final long DAY_MILLIS = 24* HOUR_MILLIS;
	public static final long HALF_DAY_MILLIS = DAY_MILLIS/2;
	public static final long WEEK_MILLIS = 7*DAY_MILLIS;
	public static final long MONTH_MILLIS = 30*DAY_MILLIS;
	public static final long HALF_MONTH_MILLIS = MONTH_MILLIS/2;
	
	public static final String DATE_DEFAULT_FORMAT = "yyyyMMdd";
	public final static String DATE_FORMAT_ALL = "yyyy-MM-dd HH:mm:ss";
	public static final String DATE_FORMAT_TRANSACTION = "dd/MM/yyyy,hh:mm";
	public static final String DATE_FORMAT_DAY_HOUR_MINUTE = "MM/dd HH:mm";
	public static final String DATE_FORMAT_HOUR_MINUTE = "HH:mm";
	public static final String DATE_FORMAT_HOUR_MINUTE_SECOND = "HH:mm:ss";
	
	public static SimpleDateFormat	 dateFormate =new SimpleDateFormat();
	public static  String toTime(long millisecond){
		return toTime(new Date(millisecond),DATE_FORMAT_ALL);
	} 
	
	public static  String toTime(long millisecond,String pattern){
		return toTime(new Date(millisecond),pattern);
	} 	
	
	public static String toTime(Date date,String pattern){
		if(TextUtils.isEmpty(pattern)){
			pattern = DATE_DEFAULT_FORMAT;
		}
		dateFormate.applyPattern(pattern);
		if(date==null){
			date = new Date();
		}
		return dateFormate.format(date);
	}
}
